import request from "@/utils/request";
import { AxiosPromise } from "axios";
import { IPage, IActivity } from "./types";

/* 查询活动列表 */
export function getPageActivityAPI(
  queryParams?: IPage
): AxiosPromise<PageResult<IActivity[]>> {
  return request({
    url: "/activity/page",
    method: "get",
    params: queryParams,
  });
}
/* 根据id查询活动对象 */
export function getFormActivityAPI(id: number): AxiosPromise<IActivity> {
  return request({
    url: `/activity/${id}/form`,
    method: "get",
  });
}

/**
 * 添加活动
 *
 * @param data
 */
export function addActivityAPI(data: any) {
  return request({
    url: "/activity",
    method: "post",
    data: data,
  });
}

/**
 * 修改活动
 *
 * @param id
 * @param data
 */
export function updateActivityAPI(id: number, data: IActivity) {
  return request({
    url: "/activity/" + id,
    method: "put",
    data: data,
  });
}

/**
 * 删除活动
 *
 * @param ids
 */
export function deleteActivityAPI(ids: number) {
  return request({
    url: "/activity/" + ids,
    method: "delete",
  });
}
